package com.example.hzly.dto;

import com.example.hzly.entity.Banner;
import lombok.Data;

import java.util.Date;


@Data
public class BannerDTO {
    private Long id;
    private String title;
    private String subtitle;
    private String imageUrl;
    private String link;
    private String buttonText;
    private Boolean isActivate;
    private Date createdAt;
    private Date updatedAt;

    // 用于创建Banner的请求DTO
    @Data
    public static class CreateBannerRequest {
        private String title;
        private String subtitle;
        private String imageUrl;
        private String link;
        private String buttonText;
        private Boolean isActivate = true;
    }

    // 用于更新Banner的请求DTO
    @Data
    public static class UpdateBannerRequest {
        private String title;
        private String subtitle;
        private String imageUrl;
        private String link;
        private String buttonText;
        private Boolean isActivate;
    }

    // 用于Banner列表展示的简略信息DTO
    @Data
    public static class BannerListItem {
        private Long id;
        private String title;
        private String imageUrl;
        private Boolean isActivate;
        private Date createdAt;
    }

    // 用于转换Entity到DTO的工具方法
    public static BannerDTO fromEntity(Banner banner) {
        BannerDTO dto = new BannerDTO();
        dto.setId(banner.getId());
        dto.setTitle(banner.getTitle());
        dto.setSubtitle(banner.getSubtitle());
        dto.setImageUrl(banner.getImageUrl());
        dto.setLink(banner.getLink());
        dto.setButtonText(banner.getButtonText());
        dto.setIsActivate(banner.getIsActivate());
        dto.setCreatedAt(banner.getCreatedAt());
        dto.setUpdatedAt(banner.getUpdatedAt());
        return dto;
    }
}